package com.example.beidouapplication;

import static java.lang.Math.floor;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.app.Fragment;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;

import com.example.beidouapplication.databinding.FragmentCepiaoBinding;
import com.example.beidouapplication.viewmodel.Key;
import com.example.beidouapplication.viewmodel.KeyEvent;

public class FragmentCepiao extends Fragment {

    static FragmentCepiao instance = new FragmentCepiao();
    Button btn_cepiao_queren;
    Button btn_cepiao_quxiao;
    TextView cepiao_question;
    TextView cepiao_time;
    TextView cepiao_hint;

    FragmentCepiaoBinding binding;

    @Override
    public View onCreateView(
            LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState
    ) {

        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_cepiao, container, false);
        binding.setTime(MainActivity.timerData);
        return binding.getRoot();
    }


    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        btn_cepiao_queren = (Button) getActivity().findViewById(R.id.cepiao_queren);
        btn_cepiao_queren.setOnClickListener(v -> {
            Menu.keyQueue.add(new KeyEvent(Key.ENTER, 1));
        });

        btn_cepiao_quxiao = (Button) getActivity().findViewById(R.id.cepiao_fanhui);
        cepiao_question = getActivity().findViewById(R.id.cepiao_question);
        cepiao_time = getActivity().findViewById(R.id.cepiao_time);
        cepiao_hint = getActivity().findViewById(R.id.cepiao_hint);
        btn_cepiao_quxiao.setOnClickListener(v -> Menu.keyQueue.add(new KeyEvent(Key.Esc, 1)));
    }


}